# coding:utf-8
# 王一舟
# 专门用来发送请求的.py


#本文件是专门用来发送请求的demo

import requests

import jsonpath

sess = requests.session()

data = {"username":"wyz","password":"123456","type":"username"}

#登录接口
rs = sess.post(url="http://127.0.0.1:5000/login",json=data)

r = rs.json()
#提取token
token  = jsonpath.jsonpath(r,"$..token")[0]

print(r)

#获取用户信息接口
rs = sess.get(url="http://127.0.0.1:5000/api/info",headers={"token":token})
print("-------------------------------------------------")
print(rs.json())